
<?php include_once __DIR__.'/../inc/userhead.html';?>
<?php include_once __DIR__.'/../inc/usermenu.html';?>
<div class="main_panel">
    <div class="panel_head"><ul class="title"><li><a href="javascript:;">我的收藏</a></li></ul></div>
    <div style="height:25px"></div>
<?php if($goodslist):?>
    <ul class="usCollect">
        <?php foreach($goodslist as $key => $value):?>
        <li>
            <a href='/goods/detail?id=<?=$value['goods_id']?>'>
                <img src='<?=$value['pic']?>'>
            </a>
            <p class='name'><a href='/goods/detail?id=<?=$value['goods_id']?>'><?=$value['title']?></a></p>
            <p class='price'>￥<?=$value['price']?></p>
            <i class='deleteColl hide'>
                <a href='javascript:delCollect(<?=$value['id']?>);' class='del_ico'><em>删除</em></a>
            </i>
        </li>
        <?php endforeach;?>
    </ul>
    <!--分页-->
    <div class="plan_pager fr">
      <div class="pageing" id='page'>
      </div>
    </div>
    <!--分页-->
    <!--分页-->
   <?php else:?>
       <p class="buyNull">还没有记录哦！</p>
  <?php endif;?>
</div>

</div>

<script>
layui.use(['laypage'], function(){
    var laypage = layui.laypage;
    //总页数大于页码总数
    laypage.render({
      elem: 'page'
      ,count:<?=$page_count?>  //数据总数
      ,curr:<?=$page?>
      ,limit:12
      ,jump: function(obj,first){
        //首次不执行
        if(!first){
            var o = GetRequest();
                o.page = obj.curr;
                o.url  = '/user/collect';
            window.location.href = createUrl(o);
        }
      }
    });
});

//删除收藏
function delCollect(id){
    $.post("/user/delCollect",{id:id},function(data){
        if(data.code==0){
            layer.msg(data.msg);
            window.location.reload();
        }else{
            layer.msg(data.msg);
        }
    },"json");
}

$(function(){
    $(".usCollect > li").hover(function(){
        $(this).children(".deleteColl").show();
    },function(){
        $(this).children(".deleteColl").hide();
    });
});
</script>

<?php include_once __DIR__.'/../inc/foot.html';?>
